1. Field of the Invention
The invention is in the field of computer graphics processor architecture and processing.
2. Description of Related Art
As is known by those skilled in the art of computer graphics, a computer typically comprises a general purpose processor that executes application program instructions and generates output data that is to be visually displayed on a monitor coupled to the computer. When performing computer graphics functions, the output data generated by the general purpose processor typically consists of a high level description of a scene for display, and other high level information such as from where the scene is to be viewed, what textures should be applied to different primitives in the scene, and where lights are located in the scene. However, the typical monitor is a simple device for accepting and outputting color information on a pixel-by-pixel basis; the typical monitor cannot interpret the output data from the application. Therefore, the output data must be processed by a graphics processor and translated into pixel color information for transmission to and display by the monitor.
A modern graphics processor frequently includes a fragment processor, also referred to as a pixel shader or pixel color processor. The fragment processor is primarily responsible for determining a final color for each fragment or pixel for which it receives information. For instance, such fragment information can include specular and diffuse lighting parameters, and texture information. However, in addition to fragment information, the fragment processor requires control information that specifies how the fragment processor is to process the fragment information to arrive at a final pixel color. The content of the control information depends on the type of fragment processor in use; one fragment processor can have a different number of computation units or computation units of a different type than another fragment processor, and would therefore require different control information or a different format of control information.
Graphics oriented Application Programming Interfaces (APIs), such as DirectX 8(trademark) and OpenGL(trademark), abstract these differences from application developers by providing a common set of commands that can be used to configure a variety of graphics processors. For instance, a version of DirectX 8 has 127 different commands available to application developers for control of a fragment processor in a graphics processor. An application developer can then arrange a sequence of commands chosen from these 127 commands, and present the sequence of commands to a driver written for the graphics processor in use. The driver converts the sequence of commands into a number of bits of control information that can directly configure the computation units of the graphics processor in use. Thus, the control information generated by the driver is specific to the architecture of the fragment processor in use and, therefore, the control information cannot be used to directly configure another type of fragment processor. This process of an application or a driver controlling a fragment processor by directly configuring its computation units with control information is known as state-based control of a fragment processor, and the information generated by the driver is known as state-based control information because the state (configuration) of computation units in the fragment processor is directly controlled by hardware or software external to the graphics processor. The set of control information active at a given time in a graphics processor is known in the art as xe2x80x9cpipeline statexe2x80x9d. Although the above-described method for controlling a fragment processor advanced the art of real-time creation of more realistic computer graphics, several limitations of state-based control methods are now evident.
One limitation is that the range of commands available for use by an application developer is inadequate for creating cutting edge computer graphics. Therefore, some application developers directly write state-based control information (created by the driver in the above example) because desired effects cannot be achieved using the commands available. Writing state-based control information is tedious, and the resulting state-based control information is likely to have errors. The resulting state-based control information is not portable to other fragment processors because the state-based control information comprehends characteristics of the fragment processor, such as the type, number, and arrangement of the fragment processor""s resources.
An alternative approach is to provide application developers with a programmable fragment processor, which is programmed (controlled) by a shader program having a number of program instructions. Typically, for generating sophisticated graphics, controlling a fragment processor with program instructions is easier for an application developer than controlling a fragment processor with state-based control information because program instructions can be represented in a higher level programming language, and program instructions allow a greater range of operations than state-based control logic. Thus, a programmable fragment processor remedies some of the deficiencies of a state-based control fragment processor.
However, controlling a fragment processor with either program instructions or state-based control information still results in limitations. One limitation is that features of a newer fragment processor may go unused by an application written to use control information of a format compatible with an older fragment processor. Also, a programmer frequently develops a familiarity with a certain format of control information, and therefore has a preference to use that format of control information, rather than another format, when writing applications. Therefore, there is a need for a fragment processor that can use a variety of control information formats for controlling its computation units to process data.
Embodiments of the invention receive control information in a plurality of formats and convert the control information into a native control format for controlling a programmable shader. In one embodiment, the invention comprises a state-based control translator for translating state-based control information into one or more codewords that natively control a programmable shader, and a program instruction translator for translating a program instruction into one or more codewords that natively control the programmable shader. Another embodiment comprises a programmable shader and a controller for detecting a start of a shader program and fetching one or more program instructions of the shader program, which are transmitted to the programmable shader. The programmable shader can begin to execute the program instructions fetched by the controller while the programmable shader fetches and translates other program instructions. Embodiments can use a memory register to store either state-based control information, if the programmable shader is to be controlled by state-based control information, or a program memory location reference identifying a memory location where one or more program instructions are stored, if the programmable shader is to be controlled by program instructions.
In one embodiment of the invention, a programmable shader for a graphics subsystem comprises a state-based control translator coupled to a data path, and configured to translate state-based control information into native control information and output the native control information to the data path. The programmer shader further comprises a program instruction translator coupled to the data path and configured to translate a program instruction into native control information and output the native control information to the data path, and a computation unit coupled to the data path to receive the native control information for configuration of the computation unit.
In another embodiment of the invention, a computing system, for processing and displaying graphical information, comprises a host computer, which comprises a host memory for storing a first program executable by the host computer to create state-based control information, and a second program executable by the host computer to create a program memory location reference. The computing system further comprises a system interface and a graphics subsystem for processing the graphical information. The graphics subsystem comprises a graphics interface coupled to the system interface for receiving the state-based control information and the program memory location reference, a local memory, and a programmable shader coupled to the interface. The programmable shader comprises a state-based control translator coupled to a data path, and configured to translate state-based control information into native control information and output the native control information to the data path. The programmer shader also comprises a program instruction translator coupled to the data path and configured to retrieve a program instruction from a memory using the program memory location reference, translate the program instruction into native control information, and output the native control information to the data path, and a computation unit coupled to the data path to receive the native control information. The computer system further comprises a display coupled to the graphics subsystem for displaying the processed graphical information.
In yet another embodiment of the invention, a graphics subsystem for processing graphical information comprises an interface coupled to receive, from a host computer, statebased control information and a program memory location reference, and further comprises a controller coupled to the interface and configured to detect the program memory location reference received by the interface and to fetch a program instruction referenced by the detected program memory location reference. The graphics subsystem also comprises a programmable shader for processing the graphical information, the programmable shader is coupled to the interface, and comprises a state-based control translator coupled to a data path and configured to translate the state-based control information into native control information and to output the native control information to the data path, a program instruction translator coupled to the data path and configured to translate the fetched program instruction into native control information and to output the native control information to the data path. The programmable shader also comprises a computation unit coupled to the data path to receive the native control information.
In still another embodiment of the invention, a programmable shader for a graphics subsystem comprises a state-based control translator coupled to a data path and configured to translate state-based control information into first native control information, and output the first native control information to the data path. The programmable shader also comprises a program instruction translator coupled to the data path, and configured to translate a program instruction into second native control information and output the second native control information to the data path. The programmable shader also comprises a first computation unit coupled to the data path to receive the first native control information and a second computation unit coupled to the data path to receive the second native control information.
In one embodiment of the invention, a method for generating native control information for controlling a programmable shader comprises the steps of determining whether the programmable shader is to be controlled by state-based control information or program instructions, receiving in a graphics subsystem state-based control information, and translating the state-based control information into native control information, if the programmable shader is to be controlled by state-based control information. If the programmable shader is to be controlled by program instructions, the method comprises receiving in a graphics subsystem a program memory location reference, fetching one or more program instructions from a memory location referenced by the program memory location reference and translating the one or more program instructions into native control information.
In another embodiment of the invention, a method for transferring control information to a programmable shader comprises receiving a control source indication specifying that the programmable shader is to be controlled by program instructions, wherein the control source indication can specify either that the programmable shader is to be controlled by state-based control information or program instructions. The method determines a memory address where a program instruction of the shader program is stored, retrieves contents of the memory address, identifies one or more program instructions in the retrieved contents, and outputs for receipt by the programmable shader the one or more program instructions.
In yet another embodiment of the invention, a method for generating native control information for controlling computation units of a programmable shader comprises receiving, in a graphics subsystem, state-based control information for control of a first computation unit and translating the state-based control information into native control information. The method also receives in the graphics subsystem a program memory location reference for identifying a memory location storing a program instruction for control of a second computation unit, fetches the program instruction, and translates the program instruction into native control information.
In yet still another embodiment of the invention, a control translator, for use in a programmable shader having a plurality of computation units for processing graphical information, comprises a codeword generator configured to input control information, wherein the control information is either state-based control information or a program instruction, and to translate the control information into native control information consisting of one or more codewords, each codeword specifying an operational configuration for one of the plurality of computation units. The control translator further comprises a sequencer configured to input the native control information and arrange the native control information in a pre-determined format compatible with at least one of the plurality of computation units.
The invention can also be embodied by a machine readable medium having embodied thereon a program, the program being executable by a machine to perform a method for generating native control information for a programmable shader. The method comprises the steps of determining whether an application uses state-based control information or program instructions for describing operations that the programmable shader is to perform on data, receiving state-based control information and translating the state-based control information into native control information, if the application uses state-based control information, and receiving one or more program instructions and translating the one or more program instructions into native control information, if the application uses program instructions.
The invention can also be embodied by a graphics subsystem comprising a means for determining a final pixel color, the means controllable by native control information, a means for translating state-based control information into the native control information, and a means for translating program instructions into the native control information.